/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author phat10130059
 */
public class StringUtil {

    public static List<String> cutString(String str) {

        List<String> tmpList = new ArrayList<String>();

        for (String retval : str.split("-")) {
            tmpList.add(retval);
        }

        return tmpList;

    }

    public static String joinString(List<String> list) {
        String tmpTitleName = "";
        for (int j = 0; j < (list.size() - 1); j++) {
            if (j == 0) {
                tmpTitleName = tmpTitleName + list.get(j);
            } else {
                tmpTitleName = tmpTitleName + "-" + list.get(j);
            }

        }
        return tmpTitleName;
    }

    public static List<String> cutStringEmptyLength(String str) {

        List<String> tmpList = new ArrayList<String>();

        for (String retval : str.split("\\s{12}")) {
            tmpList.add(retval);
        }

        return tmpList;

    }

    public static List<String> cutUrl(String str) {

        List<String> tmpList = new ArrayList<String>();

        for (String retval : str.split("\"")) {
            tmpList.add(retval);
        }

        return tmpList;

    }
    
    public static List<String> cutExe(String str){
         List<String> tmpList = new ArrayList<String>();

        for (String retval : str.split(".exe")) {
            tmpList.add(retval);
        }

        return tmpList;
    }
    
    public static String boldString(String window, String keyword){
        
         List<String> tmpList = new ArrayList<String>();
         String t = "";

        for (String str : window.toLowerCase().split(keyword.toLowerCase())) {
            tmpList.add(str);
        }
        
       if(tmpList.size() >= 2){
           t = "<html>" + tmpList.get(0) +"<font color=\"red\">"+keyword +"</font>"+ tmpList.get(1);
       }else if(tmpList.size() == 1){
           
           t = "<html>" + tmpList.get(0) +"<font color=\"red\">"+keyword +"</font>";
           
       }
        
        return t;
    }
    
    public static List<String> cutEmptyString(String str) {

        List<String> tmpList = new ArrayList<String>();

        for (String retval : str.split("\\s{8}")) {
            if(!retval.trim().equals("")){
                System.out.println(retval.trim());
                tmpList.add(retval.trim());
            }
            
        }

        return tmpList;

    }
}
